﻿using System;
using System.Collections.Generic;
using System.Text;
using CadStrategy2013.DxfData;
using MyIni;

namespace CadStrategy2013.CgqStyle
{
    public class JLDcClass:Cgq2013
    {
        public JLDcClass(string secname)
            : base(secname)
        {
        }
        public JLDcClass(string secname, Dictionary<string, string> dic)
            :base(secname,dic)
        {
        }
        public override List<string> ReadTemplateDxf()
        {
            return ReadDxf(Path + "\\template\\交流道岔电流.dll");
        }
        public override string GetSaveFileName(int index)
        {
            if (ShiJiTuZhiCount == 1)
                return "\\交流道岔电流.dxf";
            return "\\交流道岔电流" + (index + 1).ToString() + ".dxf";
        }
        public override DxfDataClass GetDxfData()
        {
            DxfDataClass dxfDataClass = new DxfDataClass();

            IniFile inifile = new IniFile("./\\" + StationName + "\\dc.txt");
            int sum0 = inifile.GetInt16("交流道岔", "sum", 0);
            string[] strDLDingXing = inifile.GetString("交流道岔", "电流定型", "").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            string str1Dqj = inifile.GetString("交流道岔", "1DQJ", "");
            string strDB = inifile.GetString("交流道岔", "DB", "");
            string strFB = inifile.GetString("交流道岔", "FB", "");
            for (int i = 0; i < sum0; i++)
            {
                DevClass devClass = new DevClass();
                string strs = inifile.GetString("交流道岔", (i + 1).ToString(), "");
                string[] s = strs.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                int n = s.Length;
                devClass.DevName = s[0];
                if (n <= 2)
                {
                    devClass.peiList.Add(str1Dqj);
                    devClass.peiList.Add(strDB);
                    devClass.peiList.Add(strFB);
                    devClass.cpeiList.Add(strDLDingXing[0]);
                    devClass.cpeiList.Add(strDLDingXing[1]);
                    devClass.cpeiList.Add(strDLDingXing[2]);
                    devClass.cpeiList.Add(strDLDingXing[3]);
                    devClass.cpeiList.Add(strDLDingXing[4]);
                    devClass.cpeiList.Add(strDLDingXing[5]);
                }
                else
                {
                    devClass.peiList.Add(s[2] + "-" + str1Dqj);
                    devClass.peiList.Add(s[2] + "-" + strDB);
                    devClass.peiList.Add(s[2] + "-" + strFB);
                    devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[0]);
                    devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[1]);
                    devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[2]);
                    devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[3]);
                    devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[4]);
                    devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[5]);
                }
                //devClass.cpeiList.Add(s[2] + "-" + strDLDingXing[1]);
                dxfDataClass.devList.Add(devClass);
            }
            if (sum0 != 0)
            {
                ShiJiBanCount = (dxfDataClass.devList.Count - 1) / BanDevCount + 1;
                ShiJiTuZhiCount = (ShiJiBanCount - 1) / BanCount + 1;
            }
            else
            {
                ShiJiBanCount = 0;
                ShiJiTuZhiCount = 0;
            }
            m_dxfDataClass = dxfDataClass;
            return dxfDataClass;
        }
    }
}
